import { ormModule } from './config/orm.module';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { LoggerMiddleware } from './config/filter/logger.filter';
import { AuthModule } from './modules/01_auth/auth.module';
import { JwtUtils } from './modules/01_auth/jwt.utils';
import { BaseModule } from './modules/00_base/base.module';
import { UserModule } from './modules/02_user/user.module';
import { RoleModule } from './modules/03_role/role.module';
import { MenuModule } from './modules/04_menu/menu.module';
import { DeptModule } from './modules/05_dept/dept.module';
import { DictModule } from './modules/06_dict/dict.module';
import { JwtService } from '@nestjs/jwt';
import { FileModule } from './modules/07_file/file.module';
import { ForecostModule } from './modules/08_fore_cost/forecost.module';
import { OrgModule } from './modules/09_org/org.module';
import { FakeModule } from './modules/09_fake/fake.module';
@Module({
  imports: [
    ormModule,
    AuthModule,
    BaseModule,
    UserModule,
    RoleModule,
    MenuModule,
    DeptModule,
    DictModule,
    FileModule,
    ForecostModule,
    OrgModule,
    FakeModule,
  ],
  providers: [JwtService, JwtUtils],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    // 日志中间件引入，匹配规则，所有路由
    consumer.apply(LoggerMiddleware).forRoutes('*');
  }
}
